
#include "ImageUtil.h"

ImageUtil::ImageUtil(){
 
}

bool ImageUtil::end(){
	GDALClose(this->ImgData);
	return true;
}

void ImageUtil::printInfo(char *FilePath){
	GDALAllRegister();
	GDALDataset *poDataset;
	poDataset = (GDALDataset *)GDALOpen(FilePath, GDALAccess::GA_ReadOnly);
	if (poDataset != NULL){
		cout << "DriverName:" << poDataset->GetDriverName() << endl;
		cout << "Description:" << poDataset->GetDescription() << endl;

		char **FileLists = poDataset->GetFileList();
		int i = 0;
		cout << "FileLists:" << endl;
		while (FileLists[i] != NULL){
			cout <<"\t"<< FileLists[i] << endl;
			i++;
		}
		cout << "ProjectionRef :" << poDataset->GetProjectionRef() << endl;

		cout << "XSize :" << poDataset->GetRasterXSize() << endl;

		cout << "YSize :" << poDataset->GetRasterYSize() << endl;

		double *Transforms = new double[6];
		poDataset->GetGeoTransform(Transforms);
		cout << "Transforms :" << endl;
		for (int i = 0; i < 6; i++){
			cout << "\t" << Transforms[i] << endl;
		}

		cout << "BandCount :" << poDataset->GetRasterCount() << endl;

		cout << "DataType : " << poDataset->GetRasterBand(1)->GetRasterDataType() << endl;

		GDALClose(poDataset);
		
	}
	else{
		cout << "Read " << FilePath << " Failed." << endl;
	}
}